package com.iyundao.io.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.iyundao.io.Service.SysRoleService;
import com.iyundao.io.model.SysRole;
import com.iyundao.io.tools.ResponseData;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by black on 2019/4/28.
 */
@RestController
@RequestMapping(value = "/api/role")
public class RoleController {

    @Autowired
    SysRoleService sysRoleService;

    @ApiOperation(value="查询管理员的角色", notes="查询管理员的角色")
    @RequestMapping(value = "/findAdminRole", method = {RequestMethod.POST,RequestMethod.GET})
    public ResponseData findAdminRole(){
        return new ResponseData(200,"获取成功",findRoleByFlag("1"));
    }

    @ApiOperation(value="查询领导的角色", notes="查询领导的角色")
    @RequestMapping(value = "/findBossRole", method = {RequestMethod.POST,RequestMethod.GET})
    public ResponseData findBossRole(){
        return new ResponseData(200,"获取成功",findRoleByFlag("2"));
    }

    @ApiOperation(value="查询党员的角色", notes="查询党员的角色")
    @RequestMapping(value = "/findPartyRole", method = {RequestMethod.POST,RequestMethod.GET})
    public ResponseData findPartyRole(){
        return new ResponseData(200,"获取成功",findRoleByFlag("3"));
    }

    private List<SysRole> findRoleByFlag(String flag){
        return sysRoleService.getRoleByFlag(flag);
    }
}
